package com.tencent.iov.cowin.befsale.clue.controller.cus;

import com.tencent.iov.cowin.befsale.clue.controller.cus.assembler.PurchaseInvoiceInfoAssembler;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.AddPurchaseInvoiceInfoRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.DeletePurchaseInvoiceInfoRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.QueryPurchaseInvoiceInfoRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.UpdatePurchaseInvoiceInfoRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.response.PurchaseInvoiceInfoResponse;
import com.tencent.iov.cowin.befsale.clue.domain.cus.po.PurchaseInvoiceInfo;
import com.tencent.iov.cowin.befsale.clue.service.cus.PurchaseInvoiceInfoService;
import com.software.boot.common.entity.Response;
import com.software.boot.common.model.dao.PageRequest;
import com.software.boot.common.model.dao.PageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Describe: 购车发票信息_Controller层
 * @author: Jason.wang
 * @created: 2022-01-24 11:51:54
 * @version: 1.0
 */
@RestController
@RequestMapping(value = "/v1/befsale/purchaseInvoiceInfo", produces = MediaType.APPLICATION_JSON_VALUE)
@Api(tags = "购车发票信息_Controller层")
public class PurchaseInvoiceInfoController {
	
	@Autowired
	private PurchaseInvoiceInfoService purchaseInvoiceInfoService;


	/**
	 * 通过ID获取详细信息
	 *
	 * @param: id
	 * @return: PurchaseInvoiceInfo对象
	 */
	@ApiOperation(value = "PurchaseInvoiceInfo管理-通过ID获取详细信息接口", httpMethod = "GET", response = Response.class, notes = "get_detail_by_id")
	@RequestMapping(path = "/get_detail_by_id", method = RequestMethod.GET)
	public Response<PurchaseInvoiceInfoResponse> getDetailById(@ApiParam(required = true, value = "对象ID", defaultValue = "1")  @RequestParam("id") Long id) {
		return Response.success(PurchaseInvoiceInfoAssembler.transformPOToResponseVo(purchaseInvoiceInfoService.getDetailById(id), PurchaseInvoiceInfoResponse.class));
	}

	/**
	 * 单条数据插入PurchaseInvoiceInfo
	 * @param request
	 * @return 插入的条数
	 */
	@ApiOperation(value = "PurchaseInvoiceInfo管理-添加信息接口", httpMethod = "POST", response = Response.class, notes = "add")
	@RequestMapping(path = "/add", method = RequestMethod.POST)
	public Response<Integer> add(@Valid @RequestBody AddPurchaseInvoiceInfoRequest request) {
		return Response.success(purchaseInvoiceInfoService.insert(PurchaseInvoiceInfoAssembler.transformVOToPO(request, PurchaseInvoiceInfo.class)));
	}

	/**
	 * 批量插入PurchaseInvoiceInfo
	 * @param requests
	 * @return 批量插入的条数
	 */
	@ApiOperation(value = "PurchaseInvoiceInfo管理-批量插入PurchaseInvoiceInfo接口", httpMethod = "POST", response = Response.class, notes = "add_batch")
	@RequestMapping(path = "/add_batch", method = RequestMethod.POST)
	public Response<Integer> addBatch(@Valid @RequestBody List<QueryPurchaseInvoiceInfoRequest> requests) {
		return Response.success(purchaseInvoiceInfoService.insertBatch(PurchaseInvoiceInfoAssembler.transformPOToResponseVoList(requests, PurchaseInvoiceInfo.class)));
	}

	/**
	 * 通过ID修改信息接口
	 *
	 * @param: request
	 * @return: 修改的条数
	 */
	@ApiOperation(value = "PurchaseInvoiceInfo管理-修改信息接口", httpMethod = "POST", response = Response.class, notes = "update")
	@RequestMapping(path = "/update", method = RequestMethod.POST)
	public Response<Integer> update(@Valid @RequestBody UpdatePurchaseInvoiceInfoRequest request) {
		return Response.success(purchaseInvoiceInfoService.update(PurchaseInvoiceInfoAssembler.transformVOToPO(request, PurchaseInvoiceInfo.class)));
	}

	/**
	 * 通过ID删除数据
	 * @param request
	 * @return 删除的条数
	 */
	@ApiOperation(value = "PurchaseInvoiceInfo管理-通过ID删除接口", httpMethod = "POST", response = Response.class, notes = "delete")
	@RequestMapping(path = "/delete", method = RequestMethod.POST)
	public Response<Integer> delete(@Valid @RequestBody DeletePurchaseInvoiceInfoRequest request) {
		return Response.success(purchaseInvoiceInfoService.delete(PurchaseInvoiceInfoAssembler.transformVOToPO(request, PurchaseInvoiceInfo.class)));
	}

	/**
	 * 根据条件查询对象list列表
	 * @param request
	 * @return 查询结果
	 */
	@ApiOperation(value = "PurchaseInvoiceInfo管理-根据条件查询对象list列表接口", httpMethod = "POST", response = Response.class, notes = "query_list_by_param")
	@RequestMapping(path = "/get_list_by_param", method = RequestMethod.POST)
	public Response<List<PurchaseInvoiceInfoResponse>> getListByParam(@RequestBody QueryPurchaseInvoiceInfoRequest request) {
		List<PurchaseInvoiceInfo> responseList = purchaseInvoiceInfoService.getListByParam(PurchaseInvoiceInfoAssembler.transformVOToPO(request, PurchaseInvoiceInfo.class));
		return Response.success(PurchaseInvoiceInfoAssembler.transformPOToResponseVoList(responseList, PurchaseInvoiceInfoResponse.class));
	}

	/**
	 * 根据条件查询对象Page记录
	 * @param request
	 * @return 查询结果
	 */
	@ApiOperation(value = "PurchaseInvoiceInfo管理-根据条件查询对象Page记录接口", httpMethod = "POST", response = Response.class, notes = "get_page_by_param")
	@RequestMapping(value = "/get_page_by_param", method = RequestMethod.POST)
	public Response<PageResponse<PurchaseInvoiceInfoResponse>> getPageByParam(@RequestBody PageRequest<QueryPurchaseInvoiceInfoRequest> request) {
		PageResponse<PurchaseInvoiceInfo> purchaseInvoiceInfoPageResponse = purchaseInvoiceInfoService.getPageByParam(PurchaseInvoiceInfoAssembler.transformVOToPOPage(request, PurchaseInvoiceInfo.class));
		return Response.success(PurchaseInvoiceInfoAssembler.transformPOToResponseVoPage(purchaseInvoiceInfoPageResponse, PurchaseInvoiceInfoResponse.class));
	}

	/**
	 * 根据条件查询单个对象
	 * @param request
	 * @return 查询结果
	 */
	@ApiOperation(value = "PurchaseInvoiceInfo管理-根据条件查询单个对象接口", httpMethod = "POST", response = Response.class, notes = "get_page_by_param")
	@RequestMapping(value = "/get_one_by_param", method = RequestMethod.POST)
	public Response<PurchaseInvoiceInfoResponse> getOneByParam(@RequestBody QueryPurchaseInvoiceInfoRequest request){
		PurchaseInvoiceInfo purchaseInvoiceInfo = purchaseInvoiceInfoService.getOneByParam(PurchaseInvoiceInfoAssembler.transformVOToPO(request, PurchaseInvoiceInfo.class));
		return Response.success(PurchaseInvoiceInfoAssembler.transformPOToResponseVo(purchaseInvoiceInfo, PurchaseInvoiceInfoResponse.class));
	}

}